package com.wrater.zero.models.checkType.service;

import com.wrater.zero.common.base.BaseException;
import com.wrater.zero.models.checkReportTemplate.dao.CheckReportTemplateMapper;
import com.wrater.zero.models.checkType.entity.CheckType;
import com.wrater.zero.models.checkType.dao.CheckTypeMapper;
import com.wrater.zero.common.base.service.AbstractService;
import com.wrater.zero.models.checkType.vo.CheckTypeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;
import java.util.Map;

/**
 * @Package: com.wrater.zero.models.checkType.service
 * @Description: <检查化验单分类服务类>
 * @Author: qiaoxs
 * @CreateDate: 2021-04-07
 * @UpdateUser: qiaoxs
 * @UpdateDate: 2021-04-07
 * @UpdateRemark: <>
 * @Version: 1.0
 */
@Service
public class CheckTypeService extends AbstractService<CheckType, CheckTypeMapper> {

    @Autowired
    CheckTypeMapper checkTypeMapper;

    @Autowired
    CheckReportTemplateMapper checkReportTemplateMapper;

    @Transactional
    public CheckTypeVO selectAllReportById(String checkTypeId){
        if (checkTypeId == null){
            BaseException.throwException("checkTypeId 不能为null", this.entityClass);
        }
        CheckTypeVO checkType = checkTypeMapper.selectAllReportById(checkTypeId);
        checkType.setCheckReportTemplateList(checkReportTemplateMapper.selectByCheckTypeId(checkType.getCheckTypeId()));
        return checkType;
    }

    public List<Map<String, String>> testSelect(String testId){
        return checkTypeMapper.testSelect(testId);
    }

}
